//
//  VisitorLoginView.swift
//  SinaWeiBo
//
//  Created by moon on 15/10/6.
//  Copyright © 2015年 moon. All rights reserved.
//

import UIKit

protocol  VisitorLoginViewDelegate :NSObjectProtocol{


 func visitorWillRegister()

 func visitorWillLogin()

}

class VisitorLoginView: UIView {

  //设置代理属性
    weak var visitorDelegate : VisitorLoginViewDelegate?
    
    @IBOutlet weak var houseicon: UIImageView!
    
    @IBOutlet weak var detailLabel: UILabel!
    
    @IBOutlet weak var smallicon: UIImageView!
    

    func setUIInfo(imageName name:String,detailText:String,isHome:Bool=false){
        
     houseicon.image=UIImage(named: name)
        
     detailLabel.text=detailText;
        
    self.smallicon.hidden = !isHome
        
        if isHome{
        
        
        startAnimation()
        
        }
        
    }
    
    private func startAnimation(){
    
        let animation=CABasicAnimation(keyPath: "transform.rotation")
        
        animation.duration=10
        
        animation.repeatCount=MAXFLOAT
    
        animation.toValue=2 * M_PI
        
        animation.removedOnCompletion=false
        
    smallicon.layer.addAnimation(animation, forKey: nil)
    
    
    }
    
    
    @IBAction func registerButton(sender: AnyObject) {
        
        visitorDelegate?.visitorWillRegister()
        
    }
    
    @IBAction func loginButton(sender: AnyObject) {
        
        visitorDelegate?.visitorWillLogin()
        
        
    }
    

}
